package com.edmond.jyframe.fragments;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.edmond.jyframe.R;
import com.edmond.jyframe.adapter.MineAdapter;
import com.edmond.jyframe.classes.MineTool;
import com.edmond.jyframe.classes.MineTools;
import com.edmond.jyframe.interfaces.view.MineToolViewInterface;
import com.edmond.jyframe.module.MineToolModel;
import com.edmond.jyframe.presenter.base.MinePresenter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by edmond on 17-4-24.
 */

public class MineFragment extends BaseFragment<MinePresenter> implements MineToolViewInterface{

    private View view;
    private Activity activity;

    private RecyclerView recyclerView;

    private List<MineTool> mineTools = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        super.onCreateView(inflater,container,savedInstanceState);

        activity = getActivity();
        view = inflater.inflate(R.layout.fragment_mine,container,false);

        recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
        recyclerView.setLayoutManager(new LinearLayoutManager(activity));
        recyclerView.setAdapter(new MineAdapter(activity,new ArrayList(),mineTools));

        getPresenter().initMineTool();

        return view;
    }

    @Override
    public Class[] initModelName() {
        Class[] classes = new Class[1];
        classes[0] = MineToolModel.class;
        return classes;
    }

    @Override
    public void initMineTool() {

    }

    @Override
    public void initedMineTool(MineTools mineTools) {
        this.mineTools.clear();
        this.mineTools.addAll(mineTools.getMineTools());
    }
}
